package com.hj.system.base.websocket;

import com.alibaba.fastjson.JSONObject;

import javax.websocket.*;

@ClientEndpoint
public class WebSocketClient {


    @OnOpen
    public void onOpen(Session session) {
        System.out.println("Connected to endpoint: " + session.getBasicRemote());
    }

    @OnMessage
    public void onMessage(String message) {
        JSONObject jsonObject = (JSONObject) JSONObject.parse(message);
        String code = jsonObject.getString("code");
        if("InventoryReal".equals(code)){

        }
    }

    @OnError
    public void onError(Throwable t) {
        t.printStackTrace();
    }

}
